
package com.trydofor.id.core;

import javax.annotation.Nonnull;

import com.trydofor.aloe.exception.FakeException;

/**
 * <pre>
 * the loader SHOULD know how to load the value and handle the exception.
 * 
 * - Load the value(s) - {@link A9Loader#heavyLoad()}
 * - Handler the exception - {@link A9Loader#handleException(Exception)}
 * </pre>
 * 
 * @param <V> the value(s) to load.
 * @author : Shi Rongjiu (www.trydofor.com)
 * @see java.util.concurrent.Future
 */
public interface A9Loader<V> {
    
    /**
     * Computes a result, or throws an exception if unable to do so.
     * 
     * @return @Nonnull computed result
     * @throws Exception if unable to compute a result
     */
    @Nonnull
    V heavyLoad() throws Exception;
    
    /**
     * handle the ExecutionException.
     * 
     * @see java.util.concurrent.Future#get()
     * @param e @Nonnull the Exception
     * @throws FakeException if can not handle it.
     */
    void handleException(@Nonnull Exception e);
}
